 		var xmlHttp;
        var url="";
        var insertplace;
        function createXMLHttpRequest() {
			if (xmlHttp == null) {
	    		if (window.ActiveXObject) {
	    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	    		}
	    		else if (window.XMLHttpRequest) {
	        		xmlHttp = new XMLHttpRequest();                
	    		}
    		}
	    }
	  
    	function addNewTag(parentId){
    		//alert(" to add new tag with parentId "+parentId);
    		var newTagName=window.prompt("????????","");
    		if(newTagName!=null && newTagName!=""){
    			createXMLHttpRequest();
    			url="subject.htm?action=addNewTag&parentId="+parentId+"&newTagName="+escape(newTagName);
    			xmlHttp.open("GET", url, true);
    			xmlHttp.onreadystatechange = callbackForAddTag;
    			xmlHttp.send(null);
    		}
    	}
    	
    	function callbackForAddTag(){
    		if(xmlHttp.readyState==4){
    			if(xmlHttp.status==200){
    				var xmlDoc = xmlHttp.responseXML;
					var nodes = xmlDoc.getElementsByTagName('number');
					var number=nodes[0].firstChild.nodeValue;
					if(number=="0")
						alert("????");
					else alert("????");
    			}
    		}
    	}
    	
    	function changeTopTag(node1,parentId){
    		var topTagId=node1.value;
    		if(topTagId=="addNewTag"){
    			addNewTag(parentId);
    			return;
    		}
    		if(topTagId==""){
    			return;
    		}
    		insertplace=node1.parentNode.parentNode.nextSibling;
    		
    		url="subject.htm?action=getChildTags&topTagId="+topTagId;
     	    createXMLHttpRequest();
			xmlHttp.open("GET", url, true);
    		xmlHttp.onreadystatechange = callback;
    		xmlHttp.send(null);
    		
    	}
    	
    	function callback(){
      		if(xmlHttp.readyState==4){
    			if(xmlHttp.status==200){
    				parseMessage();
    			}
    		}
     	}
     	
     	function parseMessage(){
      		var xmlDoc = xmlHttp.responseXML;
			var nodes = xmlDoc.getElementsByTagName('tag');
			var topnodes=xmlDoc.getElementsByTagName('topTag');
			var topTagName="";
			var topTagId;
			if(topnodes!=null){
		   		topTagId=topnodes[0].firstChild.firstChild.nodeValue;
		   		topTagName=topnodes[0].lastChild.firstChild.nodeValue;
			}
			if(nodes!=null && nodes.length>0){							
				var row=document.createElement("tr");
				var column=document.createElement("td");			
				var text=document.createTextNode(topTagName);
				column.appendChild(text);
				row.appendChild(column);
				column=document.createElement("td");	
				var select=document.createElement("select");
				select.name="tags";		
				select.onchange=function(){changeTopTag(this,topTagId);};	
				var option="";
				var id="";
				var name="";
				
				//??????
				option=document.createElement("option");
				option.value="";
				text=document.createTextNode("");
				option.appendChild(text);				
				select.appendChild(option);		
				
				//????
				for(var i=0;i<nodes.length;i++){
					option=document.createElement("option");
					id=nodes[i].firstChild.firstChild.nodeValue;
					name=nodes[i].lastChild.firstChild.nodeValue;
					//alert(id+name);
					option.value=id;
					text=document.createTextNode(name);
					option.appendChild(text);
					select.appendChild(option);								
				}
				
				//?????
				
				option=document.createElement("option");
				option.value="addNewTag";
				text=document.createTextNode("?????");
				option.appendChild(text);				
				select.appendChild(option);		
				column.appendChild(select);
				
				//????
				var image=document.createElement("img");
				image.src="images/delete.gif";
				image.onclick=function(){deleteRow(row);};
				column.appendChild(image);
				
				row.appendChild(column);
				
				insertplace.parentNode.insertBefore(row,insertplace);				
			}
		}
		
		function deleteRow(row){
			row.parentNode.removeChild(row);
		}
		